#Replication File - Credit Claiming in the European Union
#Journal: Journal of Politics

#Load in the RData file

load("Credit Claiming in the EU - Data for Tables and Figures.RData")

#Load in relevant packages for tables and figures

library(ggplot2)
library(cowplot)
library(TMB)
library(glmmTMB)
library(dplyr)
library(ggeffects)
library(quanteda)


#REGRESSION TABLES - Here is the replication code for the regression tables in the main article and the Appendix
#Note significance codes of 'summary' function. Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

#Table 3 - Fixed and Mixed Effects Regression Results

table3.1 <- glm(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO, family = "binomial")
table3.2 <- glm(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO, family = "binomial")
table3.3 <- glm(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO, family = "binomial")
table3.4 <- glm(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO, family = "binomial")
table3.5 <- glmmTMB(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country + (1 | Head.of.Government), data = EUCO, family = "binomial")
table3.6 <- glmmTMB(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country + (1 | Head.of.Government), data = EUCO, family = "binomial")

summary(table3.1)
summary(table3.2)
summary(table3.3)
summary(table3.4)
summary(table3.5)
summary(table3.6)

#Table A8: Logit model of Missing Speeches

tableA8.1 <- glm(Missing.binary ~ Partisan.Euroscepticism + Public.Euroscepticism  + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country , data = missing.analysis, family = "binomial")
tableA8.2 <- glm(Missing.binary ~ Partisan.Euroscepticism + Public.Euroscepticism  + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year +  Bargaining.Loss + Country , data = missing.analysis, family = "binomial")
tableA8.3 <- glm(Missing.binary ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + MFF + Bailout + Membership + Treaty + Country , data = missing.analysis, family = "binomial")
tableA8.4 <- glm(Missing.binary ~ Partisan.Euroscepticism + Public.Euroscepticism  + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Bargaining.Loss.Bilateral + Country , data = missing.analysis, family = "binomial")
tableA8.5 <- glm(Missing.binary ~ Partisan.Euroscepticism + Public.Euroscepticism  + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Bailout.Greece + Membership.UK + Treaty.Ireland + Country , data = missing.analysis, family = "binomial")

summary(tableA8.1)
summary(tableA8.2)
summary(tableA8.3)
summary(tableA8.4)
summary(tableA8.5)

#Table A10: Logit model of Blocking Decisions

blocking.decisions.without.uk <- subset(blocking.decisions, blocking.decisions$Country != "UK")

tableA10.1 <- glmmTMB(Block ~ eurosceptic.gov + (1 |Country) + (1 | Head.of.Government), data = blocking.decisions, family = "binomial")
tableA10.2 <- glmmTMB(Block ~ eurosceptic.gov + Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + EU.presidency + unemployment + election.year + eurosceptic.gov + Gov.EU.division + Issue.Salience + (1 |Country) + (1 | Head.of.Government), data = blocking.decisions, family = "binomial")
tableA10.3 <- glmmTMB(Block ~ eurosceptic.gov + Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + EU.presidency + unemployment + election.year + eurosceptic.gov + Gov.EU.division + Issue.Salience + (1 |Country) + (1 | Head.of.Government), data = blocking.decisions.without.uk, family = "binomial")
tableA10.4 <- glmmTMB(Block ~ Gov.EU.position + Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + EU.presidency + unemployment + election.year + Gov.EU.position + Gov.EU.division + Issue.Salience + (1 |Country) + (1 | Head.of.Government), data = blocking.decisions, family = "binomial")

summary(tableA10.1)
summary(tableA10.2)
summary(tableA10.3)
summary(tableA10.4)

#Table A12: Fixed Effects Regression Results

tableA12.1 <- glm(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO, family = "binomial")
tableA12.2 <- glm(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO, family = "binomial")
tableA12.3 <- glm(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO, family = "binomial")
tableA12.4 <- glm(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO, family = "binomial")
tableA12.5 <- glm(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country + Head.of.Government, data = EUCO, family = "binomial")
tableA12.6 <- glm(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country + Head.of.Government, data = EUCO, family = "binomial")

summary(tableA12.1)
summary(tableA12.2)
summary(tableA12.3)
summary(tableA12.4)
summary(tableA12.5)
summary(tableA12.6)

#Table A13: Random Effects Regression Results

tableA13.1 <- glmmTMB(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + (1 | Country), data = EUCO, family = "binomial")
tableA13.2 <- glmmTMB(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + (1 | Country), data = EUCO, family = "binomial")
tableA13.3 <- glmmTMB(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + (1 | Country), data = EUCO, family = "binomial")
tableA13.4 <- glmmTMB(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + (1 | Country), data = EUCO, family = "binomial")
tableA13.5 <- glmmTMB(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + (1 | Country) + (1 | Head.of.Government), data = EUCO, family = "binomial")
tableA13.6 <- glmmTMB(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + (1 | Country) + (1 | Head.of.Government), data = EUCO, family = "binomial")

summary(tableA13.1)
summary(tableA13.2)
summary(tableA13.3)
summary(tableA13.4)
summary(tableA13.5)
summary(tableA13.6)

#Table A14: Regression Results with Summit Random Effects 

tableA14.1 <- glmmTMB(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country + (1 | Head.of.Government) + (1 | CouncilID), data = EUCO, family = "binomial")
tableA14.2 <- glmmTMB(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country + (1 | Head.of.Government) + (1 | CouncilID), data = EUCO, family = "binomial")

summary(tableA14.1)
summary(tableA14.2)


#Table A15: Regression Results with CEE countries

EUCO.with.CEE <- rbind(EUCO, cee.countries)

tableA15.1 <- glm(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO.with.CEE, family = "binomial")
tableA15.2 <- glm(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO.with.CEE, family = "binomial")
tableA15.3 <- glm(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO.with.CEE, family = "binomial")
tableA15.4 <- glm(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO.with.CEE, family = "binomial")
tableA15.5 <- glmmTMB(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country + (1 | Head.of.Government), data = EUCO.with.CEE, family = "binomial")
tableA15.6 <- glmmTMB(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country + (1 | Head.of.Government), data = EUCO.with.CEE, family = "binomial")

summary(tableA15.1)
summary(tableA15.2)
summary(tableA15.3)
summary(tableA15.4)
summary(tableA15.5)
summary(tableA15.6)

#Table A16: Regression Results without UK 

EUCO.without.UK <- subset(EUCO, EUCO$Country != "UK")

TableA16.1 <- glm(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO.without.UK, family = "binomial")
TableA16.2 <- glm(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO.without.UK, family = "binomial")
TableA16.3 <- glmmTMB(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country + (1 | Head.of.Government), data = EUCO.without.UK, family = "binomial")
TableA16.4 <- glmmTMB(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country + (1 | Head.of.Government), data = EUCO.without.UK, family = "binomial")

summary(TableA16.1)
summary(TableA16.2)
summary(TableA16.3)
summary(TableA16.4)


#Table A17: Regression Results with Interaction

TableA17.1 <- glm(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism *Gov.EU.position + Gov.Trust  + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO, family = "binomial")
TableA17.2 <- glm(Share ~ Partisan.Euroscepticism + Public.Euroscepticism*Gov.EU.position + Gov.Trust  + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO, family = "binomial")
TableA17.3 <- glm(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism*Gov.EU.position + Issue.Salience + Gov.Trust  + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO, family = "binomial")
TableA17.4 <- glm(Share ~ Partisan.Euroscepticism + Public.Euroscepticism*Gov.EU.position + Issue.Salience + Gov.Trust  + Gov.EU.division + EU.presidency + unemployment + election.year + Country, data = EUCO, family = "binomial")
TableA17.5 <- glmmTMB(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism*Gov.EU.position + Issue.Salience + Gov.Trust  + Gov.EU.division + EU.presidency + unemployment + election.year + Country + (1 | Head.of.Government), data = EUCO, family = "binomial")
TableA17.6 <- glmmTMB(Share ~ Partisan.Euroscepticism + Public.Euroscepticism*Gov.EU.position + Issue.Salience + Gov.Trust+ Gov.EU.division + EU.presidency + unemployment + election.year + Country + (1 | Head.of.Government), data = EUCO, family = "binomial")

summary(TableA17.1)
summary(TableA17.2)
summary(TableA17.3)
summary(TableA17.4)
summary(TableA17.5)
summary(TableA17.6)



#Table A18: Regression Results with Country Coefficients (from Polynomial Quadratic Model)

EUCO$Country <- relevel(EUCO$Country, ref = "FR")

TableA18.1 <- glm(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country + Year_Alt + I(Year_Alt^2), data = EUCO, family = "binomial")
TableA18.2 <- glm(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country + Year_Alt + I(Year_Alt^2), data = EUCO, family = "binomial")
TableA18.3 <- glm(Claim ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country  + Year_Alt + I(Year_Alt^2), data = EUCO, family = "binomial")
TableA18.4 <- glm(Share ~ Partisan.Euroscepticism + Public.Euroscepticism + Issue.Salience + Gov.Trust + Gov.EU.position + Gov.EU.division + EU.presidency + unemployment + election.year + Country  + Year_Alt + I(Year_Alt^2), data = EUCO, family = "binomial")

summary(TableA18.1)
summary(TableA18.2)
summary(TableA18.3)
summary(TableA18.4)
